%%%HEADER%%%

OpenFeint Android Quick Start Guide

<<Prev Next >>
 

Integrating GameFeed into your game

To get GameFeed up and running in your game:
  1. Before you integrate GameFeed into your game, make sure you've updated your OpenFeint integration to the current version of OpenFeintAPI.
  2. High Level Integration Overview
    To prepare your code for GameFeed, here's what you do:
    1. Update your main menu UI and layout to make space for the GameFeed UI element.
      - For Portrait, you will need to clear an approximately 76 pixel high space to fit the game bar. (The actual number of pixels will vary with the screen resolution of the target device.)
      - For Landscape, you will need to clear an approximately 62 pixel high space to fit the game bar. (The actual number of pixels will vary with the screen resolution of the target device.).
    2. Include the GameFeed API code as described here (the easy part).
  3. Link against the GameFeed library:
    • In Eclipse:
      Import the GameFeed library into your project:
      1. Right-click the application project.
      2. Click Import.
      3. Click Existing Projects into Workspace..
      4. Click Next.
      5. Browse to the directory in which the OpenFeintAPI and GameFeed libraries are stored.
      6. Click OK.
      7. If OpenFeintAPI is not yet imported, click its checkbox.
      8. If GameFeed is not yet imported, click its checkbox.
      9. Click Finish.
      10. Build the OpenFeint and GameFeed libraries.
    • In Ant:
      1. Edit the default.properties file in your game project's directory.
      2. There should already be an android.library.reference.1 entry for your reference to OpenFeintAPI. Add an android.library.reference.2 entry that points to the GameFeed folder in the unzipped release. If the GameFeed folder is a sibling to your game project folder, it should look like this:
        android.library.reference.2=../GameFeed
  4. Integrate

    There is an example of how to use GameFeed in the provided sample application. See MyOpenFeintSample/src/com/openfeint/example/GameFeedPage.java for details.

    Basically, to integrate GameFeed:
    1. Make sure OpenFeint is initialized first (in the onCreate() method of your Application class).
    2. in the onCreate() method of the Activity class in which you want to show GameFeed, create a
      Map
      with all the settings you want to configure GameFeed. Take a look at GameFeed/src/com/openfeint/gamefeed/GameFeedSettings for the full set of keys you can configure.
    3. Create a new GameFeedView with
      GameFeedView gameFeedView = new GameFeedView(this, your_settings_map);
    4. Add gameFeedView to your layout. The easiest way to do this is
      gameFeedView.addToLayout(this.findViewById(R.id.root_layout_id));
  5. Add to your layout

    GameFeedView#addToLayout(View) works on LinearLayout, RelativeLayout, and FrameLayout classes. It works best on the FrameLayout class (i.e. if you animate in and out, it won't shift your content around). If your root layout isn't one of these classes, it may be worth adding a FrameLayout at the root of your layout hierarchy and using that as the layout that you add GameFeedView to.

    If you want to position your GameFeedView in a custom way, you should be able to simply call yourLayout.addView(gameFeedView) without any trouble, but be aware that if you go with this implementation, none of the alignment or animation settings will work.
  6. Hiding and showing

    Call hide() or show() on your GameFeedView when you want to specifically hide or show it. These methods are necessary if you've enabled the animation setting (see GameFeedSettings.AnimateIn), but if you just want to show and hide the view without animating, you can simply call setVisibility(View.GONE) or setVisibility(View.VISIBLE).